import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { coreKhdaListData } from '/@/api/bas/cus/coreKhda';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('客户选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 100,
  schemas: [
    {
      label: t('单位编码'),
      field: 'khdaDwbm',
      component: 'Input',
    },
    {
      label: t('单位名称'),
      field: 'khdaDwqc',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('单位编码'),
    dataIndex: 'khdaDwbm',
    key: 'a.khda_dwbm',
    sorter: true,
    width: 230,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('单位简称'),
    dataIndex: 'khdaDwjc',
    key: 'a.khda_dwjc',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('单位全称'),
    dataIndex: 'khdaDwqc',
    key: 'a.khda_dwqc',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('单位分类'),
    dataIndex: 'khdaDwfl',
    key: 'a.khda_dwfl',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'car_cus_cls',
  },
  {
    title: t('业务员'),
    dataIndex: 'person.userName',
    key: 'a.khda_ywy',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('单位地址'),
    dataIndex: 'khdaDwdz',
    key: 'a.khda_dwdz',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('结算方式'),
    dataIndex: 'khdaJsfs',
    key: 'a.khda_jsfs',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'car_settle_tpye',
  },
  {
    title: t('结算周期'),
    dataIndex: 'khdaJszq',
    key: 'a.khda_jszq',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'car_settle_cycle',
  },
  {
    title: t('授信额度'),
    dataIndex: 'khdaSxed',
    key: 'a.khda_sxed',
    sorter: true,
    width: 130,
    align: 'right',
  },
  {
    title: t('状态'),
    dataIndex: 'status',
    key: 'a.status',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_search_status',
  },
  {
    title: t('备注'),
    dataIndex: 'remarks',
    key: 'a.remarks',
    sorter: true,
    width: 130,
    align: 'left',
  },
];

const tableProps: BasicTableProps = {
  api: coreKhdaListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'khdaDwbm',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'khdaDwbm',
  itemName: 'khdaDwqc',
  isShowCode: true,
};
